@extends('layouts.layouts')
@section('title')
    <title>用户列表</title>
    <link rel="stylesheet" href="/css/xadmin.css">


@endsection
@section('content')

<div class="content">
        <div class="header">       
            <h1 class="page-title">课程分类列表</h1>
             <ul class="breadcrumb"></ul>
        </div>
        <div class="main-content">
<div class="btn-toolbar list-toolbar">
    <a href="/ctype/add"><button class="btn btn-primary"><i class="fa fa-plus"></i>添加课程分类</button></a>

  <div class="btn-group">
  </div>
</div>
 <div class="panel panel-default">
   <div class="panel-heading no-collapse">课程分类列表<!-- <span class="label label-warning">+10</span> table-bordered --></div>

         <table class="layui-table layui-form">
             <thead>
             <tr>
                 <!--<th width="20">
                     <div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i></div>
                 </th>-->
                 <th width="70">ID</th>
                 <th>栏目名</th>

                 {{--<th width="10%">排序</th>--}}
                 {{--<th width="10%">状态</th>--}}
                 

                 <th width="10%">排序值</th>
                 <th width="10%">类别说明</th>
                <th width="10%">课程</th>
                 <th width="20%">操作</th>
             </thead>
             <tbody class="x-cate">
             @foreach($data as $c=>$k)
             <tr cate-id='{{$k->id}}' fid='{{$k->pid}}' >
                 <!--<td>
                     <div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id='2'><i class="layui-icon">&#xe605;</i></div>
                 </td>-->
                 <td>{{$k->id}}</td>
                 <td>
                     <i class="layui-icon x-show" status='false'>&#xe625;</i>
                     {{$k->title}}
                 </td>
                <td>{{$k->orderby}}</td>
                <td>{{$k->description ? $k->description : '--'}}</td>
                 {{--<td>--}}
                     {{--<input  id="checkbox1" type="checkbox" name="switch"  lay-text="开启|停用"  checked="" lay-skin="switch"> onclick="x_admin_show('编辑','/ctype/show?id={{$k->id}}')"--}}
                 {{--</td>--}}
                 <td>
                      <button class="layui-btn layui-btn-xs layui-btn-primary"  onclick="window.location.href='/ctype/cindex/1/{{$k->id}}';" >查看详情</button>
                 </td>
                 <td class="td-manage">
                     <button class="layui-btn layui-btn layui-btn-xs"  onclick="window.location.href='/ctype/cedit?id={{$k->id}}';" ><i class="layui-icon">&#xe642;</i>编辑</button>
                     <button class="layui-btn layui-btn-warm layui-btn-xs"  onclick="window.location.href='/ctype/show?id={{$k->id}}';" ><i class="layui-icon">&#xe642;</i>添加子栏目</button>
                     <button class="layui-btn-danger layui-btn layui-btn-xs"  onclick="member_del(this,'{{$k->id}}')" href="javascript:;" ><i class="layui-icon">&#xe640;</i>删除</button>
                 </td>
             </tr>

             <!--erji-->
             @foreach($k->child as $v)
             <tr cate-id='{{$v->id}}' fid='{{$v->pid}}' >
                 {{--<td>--}}
                     {{--<div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id='2'><i class="layui-icon">&#xe605;</i></div>--}}
                 {{--</td>--}}
                 <td>{{$v->id}}</td>
                 <td>
                     &nbsp;&nbsp;&nbsp;&nbsp;
                     <i class="layui-icon x-show" status='false'>&#xe625;</i>
                     {{$v->title}}
                 </td>
                 <td>--</td>
                 <td>{{$v->description ? $v->description : "暂无说明"}}</td>
                 {{--<td>--}}
                     {{--<input  id="checkbox1" type="checkbox" name="switch"  lay-text="开启|停用"  checked="" lay-skin="switch">--}}
                 {{--</td>--}}
                  <td>
                      <button class="layui-btn layui-btn layui-btn-xs layui-btn-primary"  onclick="window.location.href='/ctype/cindex/2/{{$v->id}}';" >查看详情</button>
                 </td>
                 <td class="td-manage">
                     <button class="layui-btn layui-btn layui-btn-xs"  onclick="window.location.href='/ctype/cedit?id={{$v->id}}'" ><i class="layui-icon">&#xe642;</i>编辑</button>
                     <button class="layui-btn layui-btn-warm layui-btn-xs"  onclick="window.location.href='/ctype/show?id={{$v->id}}'" ><i class="layui-icon">&#xe642;</i>添加子栏目</button>
                     <button class="layui-btn-danger layui-btn layui-btn-xs"  onclick="member_del(this,'{{$v->id}}')" href="javascript:;" ><i class="layui-icon">&#xe640;</i>删除</button>
                 </td>
             </tr>
             @foreach($v->child as $b)
             <tr cate-id='{{$b->id}}' fid='{{$b->pid}}' >
                 {{--<td>--}}
                     {{--<div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id='2'><i class="layui-icon">&#xe605;</i></div>--}}
                 {{--</td>--}}
                 <td>{{$b->id}}</td>
                 <td>
                     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                     ├{{$b->title}}
                 </td>
                 <td>--</td>
                 <td>{{$b->description ? $b->description : "暂无说明"}}</td>
                 {{--<td>--}}
                     {{--<input id="checkbox1" type="checkbox" name="switch"  lay-text="开启|停用"  checked="" lay-skin="switch">--}}
                 {{--</td>--}}
                  <td>
                      <button class="layui-btn layui-btn layui-btn-xs layui-btn-primary"  onclick="window.location.href='/ctype/cindex/3/{{$b->id}}';" >查看详情</button>
                 </td>
                 <td class="td-manage">
                     <button class="layui-btn layui-btn layui-btn-xs"  onclick="window.location.href='/ctype/cedit?id={{$b->id}}'" ><i class="layui-icon">&#xe642;</i>编辑</button>
                     <!--<button class="layui-btn layui-btn-warm layui-btn-xs"  onclick="x_admin_show('编辑','admin-edit.html')" ><i class="layui-icon">&#xe642;</i>添加子栏目</button>-->
                     <button class="layui-btn-danger layui-btn layui-btn-xs"  onclick="member_del(this,'{{$b->id}}')" href="javascript:;" ><i class="layui-icon">&#xe640;</i>删除</button>
                 </td>
             </tr>

             @endforeach
             @endforeach
             @endforeach
             </tbody>
         </table>


</div>


</div>
   
    <script type="text/javascript" src="/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/js/xadmin.js"></script>

    <script>

        $(".link").click(function(){
           // console.log($(this).next());
            $(this).next().toggleClass('submenu1');
        })

    </script>
    <script>
        layui.use(['form'], function(){
            form = layui.form;

        });
        /*用户-删除*/
        function member_del(obj,id){
            layer.confirm('确认要删除吗？',function(index){
                //发异步删除数据
                console.log(id);
                $.get("/ctype/det",{id:id},function(data){
                    console.log(data);
                });
                $(obj).parents("tr").remove();
                layer.msg('已删除!',{icon:1,time:1000});
            });
        }

        function delAll (argument) {

            var data = tableCheck.getData();

            layer.confirm('确认要删除吗？'+data,function(index){
                //捉到所有被选中的，发异步进行删除
                layer.msg('删除成功', {icon: 1});
                $(".layui-form-checked").not('.header').parents('tr').remove();
            });
        }


    </script>

@endsection
